require(["frontmain"], function () {
    require(["jquery", "layer", "base", "front", "store.min"], function () {
        store = require("store.min"), F_Login_Entrance._init()
    })
});
var F_Login_Entrance = {
    _init: function () {
        console.log("初始化登入按钮");

        $('input[name="username"]').val(B_Login._pre()), B_Captcha._getCaptcha("div_gt_embed"), B_Common._submitBind($("#bs_login_btn"),
            $('input[name="username"],input[name="userpass"],input[name="usercaptcha"]')),
            F_Login._check(),

            //F_Login._sms(),
            //F_Login._refresh(),


            B_Common._isInner() ? (B_AD._ad("ad_3", "item.html?k=1"),
                B_Login._backUrl("set", B_Common._parentUrl()),
                F_Login._typeChange("inner")) : (F_Login._typeChange("page"),
                S_HeadFoot._getLoginHead("进入控制台"),
                B_Login._backUrl("set"), $(".h-logo").click(function () {
            B_Jump._go("target", "index")
        }))
    }
}, F_Login = {
    _getType: function () {
        var e = "";
        return B_Common._isInner() ? $(".lg_tab span").each(function (t) {
            if ($(this).hasClass("lg_tabOn"))switch (t + "") {
                case"0":
                    e = "p";
                    break;
                case"1":
                    e = "c"
            }
        }) : e = $("#bs_type a").attr("data-t"), e
    }, _refresh: function () {
        var e = B_Common._baseHost() + B_Jump._getUrl("refresh");
        e = B_Common._encodeUrl(e), $(".bs_qq").click(function () {
            B_Login._setStatus("out"), B_Jump._go("base", B_Port._init("qqLogin") + "?redirect_url=" + e)
        }), $(".bs_wx").click(function () {
            B_Login._setStatus("out"), B_Jump._go("base", B_Port._init("wxLogin") + "?redirect_url=" + e)
        })
    }, _sms: function () {
        $("#bs_sms_send").click(function () {
            var e = $.trim($('input[name="username"]').val());
            return !!F_Login._checkMobile("c", e) && (B_CaptchaObj && B_CaptchaObj.getValidate() ? (F_Login._notice(2, ""), void F_Login._existsMobile(e)) : (F_Login._notice(2, "请滑动验证"), !1))
        })
    }, _check: function () {
        $("#bs_login_btn").click(function () {
            console.log("3333333333333")
            var e = F_Login._checkForm();
            console.log("e is",e);
            if (!e)return !1;

            var t = "";
           /* if (B_Common._isInner()) {
                var n = B_Common._getUrl("query");
                if (n.from)switch (n.from) {
                  /!*  default:
                        var i = n.from.split("_");
                        if (2 == i.length)switch (i[0]) {
                            case"a":
                                t = "outside.html#/outsideAtlas/" + i[1];
                                break;
                            case"l":
                                t = "outside.html#/gameLight/" + i[1]
                        }
                        break;
                    case"service":
                        t = B_Jump._getUrl("main");
                        break;
                    case"app":
                        t = B_Jump._getUrl("index") + "?f=app";
                        break;
                    case"background":
                        t = "";
                        break;
                    case"outsideCenter":
                    case"outsideAlarm":
                    case"outsideHotWord":
                    case"outsideAssistant":
                    case"outsideChat":
                    case"outsideFaceSummary":
                    case"insideSummary":
                    case"gameSummary":
                    case"gameSentiment":
                    case"gameForum":
                        t = B_Jump._getUrl(n.from)*!/
                }
                "" == t && (n.from && "background" == n.from || (t = B_Common._parentUrl(), t.indexOf("#") > -1 && (t = t.split("#")[0])))
            } else*/

            t = B_Jump._getUrl("/main/index");
            console.log("t B_Jump is",t);

            return B_Login._in(e, function () {
                $("#bs_login_btn").html("登录中,请稍等...").attr("disabled", !0)
            }, function () {
                $("#bs_login_btn").html("登录").attr("disabled", !1)
            }, t), !1
        })
    }, _typeChange: function (e) {
        switch (e) {
            case"inner":
                $(".lg_tab span").each(function (e) {
                    $(this).click(function () {
                        switch ($(this).addClass("lg_tabOn").siblings("span").removeClass("lg_tabOn"), e + "") {
                            case"0":
                                $("#bs_u_0").show(), $("#bs_u_1").hide();
                                break;
                            case"1":
                                $("#bs_u_1").show(), $("#bs_u_0").hide()
                        }
                    })
                });
                break;
            case"page":
                $("#bs_type a").click(function () {
                    var e = $(this).attr("data-t"), t = $("#bs_type label");
                    switch (e) {
                        case"c":
                            $(this).attr("data-t", "p"), $(".bs_pass").show(), $(".bs_code").hide(), t.html("使用验证码登录");
                            break;
                        case"p":
                            $(this).attr("data-t", "c"), $(".bs_pass").hide(), $(".bs_code").show(), t.html("使用帐号密码登录")
                    }
                })
        }
    }, _checkForm: function () {
        var e = F_Login._getType(),
            t = $.trim($('input[name="username"]').val()),
            n = $.trim($('input[name="userpass"]').val()),
            i = $.trim($('input[name="usercaptcha"]').val()), _ = 0,
            o = {};

        if (!F_Login._checkMobile(e, t))return !1;
        switch (e + "") {
            case"p":
                if ("" == n)return F_Login._notice(1, "密码不能为空"), !1;
                F_Login._notice(1, ""), o.password = n;
                break;
            case"c":
                if ("" == i)return F_Login._notice(2, "短信验证码不能为空"), !1;
                F_Login._notice(2, ""), o.logintype = "verify", o.verify_code = i
        }
        return 1 == $('input[name="userexpire"]').prop("checked") && (_ = 604800), o.login_name = t, o.userpass = n, o
    }, _notice: function (e, t) {
        console.log("notice t is:",t);

        t && B_Pop._init("msg", {content: t})
    }, _checkMobile: function (e, t) {
        console.log("点击登入",e)
        console.log("点击登入",t);
        console.log("手机号不能为空",t);

        if ("" == t){
            console.log("手机号为空",t);
            return F_Login._notice(0, "手机号不能为空"), !1;
        }

        switch (F_Login._notice(0, ""), e + "") {
            case"p":
                var n = "auto";
                if (B_Common._isInner() && (n = ["190px", "50px"]), B_Common._isMail(t))return B_Pop._init("msg", {
                    offset: n,
                    content: "尊敬的用户，考虑到数据安全性，我们已关闭邮箱登录功能。建议您采用手机号注册登录"
                }), !1;
                if (!B_Common._isMobile(t))return F_Login._notice(0, "手机号格式错误"), !1;
                F_Login._notice(0, "");
                break;
            case"c":
                if (!B_Common._isMobile(t))return F_Login._notice(0, "手机号格式错误"), !1;
                F_Login._notice(0, "")
        }
        return !0
    }, _existsMobile: function (e) {
        var t = $("#bs_sms_send"), n = {};
        n.mobile = e, n = B_Common._postData(n), B_Port._ajax("register", "get", !0, n, function () {
            t.text("手机验证中").attr("disabled", !0)
        }, function () {
            t.text("获取验证码").attr("disabled", !1)
        }, function (t, n) {
            return t.mobile_exist + "" == "0" ? (F_Login._notice(0, "当前手机号码未注册"), !1) : void B_Captcha._getVCode(e)
        }, function (e, t, n) {
            return B_Port._init("msg", {content: t}), !1
        })
    }
};